/**
 * @description
 * @author ybjuejue
 * @createDate 2018/12/27/027
 */
;(function () {
    var m3, m3Cache, m3Ajax;
    define(function (require, exports, module) {
        m3 = require('m3');
        m3Ajax = require('ajax');
        m3Cache = require('nativeCache');
        var life = __$clockpage__({
            state: {
              mapInfo: {
                type: '',
                state: false
              }
            },
            mutations: {
                setMapInfo: function (context, info) {
                  context.setState({
                     mapInfo:info
                  })
                }
            }
        });
        var ss= new life('#pageFooter', {
            $onloaded: function () {
                $cmp('body').append(this.render());
            },
            methods: {
                menuList: {
                    my: {
                        title: '我的'
                    }, //我的模块是否显示
                    setting: {
                        title: '设置'
                    },
                    statistics: {
                        title: '统计'
                    },
                    footprint: {
                        title: '足迹'
                    },
                    clock: {
                        title: '打卡'
                    }
                },
                menuAuthority: {
                    my: true, //我的模块是否显示
                    setting: true,
                    statistics: true, //统计模块是否显示
                    footprint: true, //足迹模块是否显示
                    clock: true //打卡模块是否显示
                },
                render: function () {
                    var that = this;
                    console.log(this);
                    var menuString = '';
                    for (var key in this.menuAuthority) {
                        if (this.menuAuthority[key]) {
                            menuString += '<li class="flex-1" type="' + key + '">' + this.menuList[key].title + '</li>'
                        }
                    }
                    ;
                    if (menuString) {
                        menuString = '<div class="clock-page-footer"><ul class="flex-h">' + menuString + '</ul><div>';
                        var menuDom = $cmp(menuString);
                        menuDom.on('tap', 'li', function (e) {
                            var type = $(this).attr('type');
                            console.log(e)
                            that.store.commit('setMapInfo', {
                                type: that.menuList[type].title,
                                state: false
                            });
                            console.log(type)
                        });

                    }
                    return menuDom;
                }
            }
        });
        console.log(ss)
        new life('map', {
            $onloaded: function () {

                $cmp('body').append(this.render());
            },
            watch: {
                mapInfo: function (val, old) {
                    console.log(val);
                  if (val) {

                  }
                }
            },

            methods: {
                render: function () {
                    return '';
                }
            }
        })
    })
})();